package com.qiaofang.dataprocessing.service.impl;

import com.google.common.collect.Lists;
import com.qiaofang.dataprocessing.dao.FirsthandEstateDao;
import com.qiaofang.dataprocessing.service.FirsthandEstateService;
import com.qiaofang.dataprocessing.stub.bean.FirsthandRulesDTO;
import com.qiaofang.dataprocessing.stub.bean.request.FirsthandUpDownProcessingRequest;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.LinkedList;
import java.util.List;

/**
 * Created by IDEA.
 *
 * @auther Zym.
 * @company qiaofang
 * @date 2020/11/18 17:18
 */
@Service
@Slf4j
public class FirsthandEstateServiceImpl implements FirsthandEstateService {
    @Autowired
    private FirsthandEstateDao firsthandEstateDao;

    @Override
    public List<String> getUpEstateUuidList(FirsthandUpDownProcessingRequest processingRequest) {
        List<String> resultList = new LinkedList<>();
        FirsthandRulesDTO firsthandRules = processingRequest.getFirsthandRules();
        List<String> uuidList = processingRequest.getUuidList();
        List<List<String>> partition = Lists.partition(uuidList, 1800);
        for (List<String> list : partition) {
            firsthandRules.setUuidList(list);
            resultList.addAll(firsthandEstateDao.getUpEstateUuidList(firsthandRules));
        }
        return resultList;
    }
}
